import React,{ PureComponent } from 'react';
import PropTypes from 'prop-types'
import { connect } from 'react-redux';

import { Button } from 'antd';
import './index.less'

/*const ButtonEvent=({
    data=[],
    style={}
})=>{
    return(
        <div className="btntool" style={style}>
            {
                data.map((item)=>{
                    return <Button {...item} >{item.value}</Button>
                })
            }
        </div>
    );
}*/
class ButtonEvent extends PureComponent{
    render(){
        const { data,style,btnloading } = this.props;
        return(
            <div className="btntool" style={style}>
                {
                    data.map((item)=>{
                        return item.hasOwnProperty('btnloading')?<Button {...item} loading={btnloading} >{item.value}</Button>:<Button {...item} >{item.value}</Button>
                    })
                }
            </div>
        )
    }
}


ButtonEvent.propTypes = {
    data:PropTypes.array.isRequired
}

const mapStateToProps = (state)=>{
    const btnloading = state.getIn(['main','btnloading']);
    return{
        btnloading
    }
}
const mapDispatchToProps = (dispatch)=>{
    return{
    }
}
export default connect(mapStateToProps,mapDispatchToProps)(ButtonEvent);